package com.bling.service;

import java.io.Serializable;
import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bling.common.bean.Admin;
import com.bling.common.idao.IAdminDao;
import com.bling.iservice.IAdminService;
/**
 * 管理员服务实现
 * @author BLingSoft
 *
 */
@Service
public class AdminService implements IAdminService {

	public void saveAdmin(Admin admin) throws SQLException{
		adminDao.save(admin);
	}

	public void deleteAdmin(Admin admin)  throws SQLException{
		adminDao.delete(admin);
	}

	public void deleteAdminById(Serializable id)  throws SQLException{
		adminDao.delete(Admin.class, id);
	}

	public Admin findAdminById(Serializable id)  throws SQLException{
		return adminDao.find(Admin.class, id);
	}

	public Admin findAdminByUsername(String username)  throws SQLException{
		String hql = "from Admin a where a.username=?";
		return adminDao.find(hql, new Object[]{username});
	}

	public void updateAdmin(Admin admin) throws SQLException {
		adminDao.update(admin);
	}
	
	private IAdminDao adminDao;

	public IAdminDao getAdminDao() {
		return adminDao;
	}
	
	@Resource
	public void setAdminDao(IAdminDao adminDao) {
		this.adminDao = adminDao;
	}
}
